package com.ruoyi.web.controller.tuike;

import com.ruoyi.tiktok.domain.Video;
import com.ruoyi.tiktok.service.VideoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/videos")
public class VideoController {
    @Autowired
    private VideoService videoService;

    @PostMapping
    public void createVideo(@RequestBody Video video) {
        videoService.createVideo(video);
    }

    @PutMapping("/{videoId}")
    public void updateVideo(@PathVariable String videoId, @RequestBody Video video) {
        video.setVideoId(videoId);
        videoService.updateVideo(video);
    }

    @DeleteMapping("/{videoId}")
    public void deleteVideo(@PathVariable String videoId) {
        videoService.deleteVideo(videoId);
    }

    @GetMapping("/{videoId}")
    public Video getVideoById(@PathVariable String videoId) {
        return videoService.getVideoById(videoId);
    }
}

